package com.shadow.repository;

import com.shadow.domain.AccountInfo;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 * Created by qq65827 on 2014/9/2.
 */
public class UserDaoImpl implements UserDao {
    public AccountInfo save(AccountInfo accountInfo) {
        EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("shadow");
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        entityManager.getTransaction().begin();
        entityManager.persist(accountInfo);
        entityManager.getTransaction().commit();
        entityManagerFactory.close();
        return accountInfo;
    }
}
